/**
 * 是否是debugger模式
 * @returns {boolean}
 */
/** 系统设置 开始 **/
!window.sysConfig && (window.sysConfig = {
    debuggerHost: ['dm.leyaoyao.com'],
    prodHost: ['m.leyaoyao.com'],
    testHost: ['sm.leyaoyao.com']
})
let baseHost = ['localhost', '192.168', '127.0.0.1']
function isDebuggerMode(options) {
    let url = window.location.href
    let host = window.location.host

    if (window.sysConfig && window.sysConfig.debuggerHost) { // 需要设置debuggerHost 名单
        baseHost = isArray(sysConfig.debuggerHost) ? baseHost.concat(sysConfig.debuggerHost) : baseHost
    }

    function isArray(item) {
        return Object.prototype.toString.apply(item) === '[object Array]'
    }

    function isString(item) {
        return typeof item === 'string'
    }

    let openDebuggerHost = options && isArray(options.openDebuggerHost) ? options.openDebuggerHost.contact(baseHost) : baseHost
    let checkIsHost = function(arr, val) {
        let tempFlag = false
        if (arr && isArray(arr) && val && isString(val)) {
            for (let i = 0; i < arr.length; i++) {
                if (val.search(arr[i]) > -1) {
                    return tempFlag = true
                }
            }
            return tempFlag
        } else {
            return tempFlag
        }
    }
    if (checkIsHost(openDebuggerHost, host) || url.search('debug=1') > -1) {
        return window.debugMode = true
    } else {
        return window.debugMode = false
    }
}
export default isDebuggerMode